home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Shareware / DeviceLock 6.2.11337 / setup.exe / Main / DLServer.exe / 0 / SQL / 103 next >
Encoding:
Text (UTF-16)  |  2007-11-12  |  17.3 KB  |  412 lines

  1. CREATE DATABASE "%DBNAME%"
  2. GO
  3.  
  4. EXEC sp_dboption "%DBNAME%", N'autoclose', N'true'
  5. GO
  6.  
  7. EXEC sp_dboption "%DBNAME%", N'torn page detection', N'true'
  8. GO
  9.  
  10. EXEC sp_dboption "%DBNAME%", N'read only', N'false'
  11. GO
  12.  
  13. EXEC sp_dboption "%DBNAME%", N'dbo use', N'false'
  14. GO
  15.  
  16. EXEC sp_dboption "%DBNAME%", N'single', N'false'
  17. GO
  18.  
  19. EXEC sp_dboption "%DBNAME%", N'autoshrink', N'false'
  20. GO
  21.  
  22. EXEC sp_dboption "%DBNAME%", N'ANSI null default', N'false'
  23. GO
  24.  
  25. EXEC sp_dboption "%DBNAME%", N'recursive triggers', N'false'
  26. GO
  27.  
  28. EXEC sp_dboption "%DBNAME%", N'ANSI nulls', N'false'
  29. GO
  30.  
  31. EXEC sp_dboption "%DBNAME%", N'concat null yields null', N'false'
  32. GO
  33.  
  34. EXEC sp_dboption "%DBNAME%", N'cursor close on commit', N'false'
  35. GO
  36.  
  37. EXEC sp_dboption "%DBNAME%", N'default to local cursor', N'true'
  38. GO
  39.  
  40. EXEC sp_dboption "%DBNAME%", N'quoted identifier', N'false'
  41. GO
  42.  
  43. EXEC sp_dboption "%DBNAME%", N'ANSI warnings', N'false'
  44. GO
  45.  
  46. EXEC sp_dboption "%DBNAME%", N'auto create statistics', N'true'
  47. GO
  48.  
  49. EXEC sp_dboption "%DBNAME%", N'auto update statistics', N'true'
  50. GO
  51.  
  52. USE "%DBNAME%"
  53. GO
  54.  
  55. CREATE TABLE [DLServers] (
  56.     [ServerId] [int] IDENTITY (1, 1) NOT NULL ,
  57.     [ServerGuid] [uniqueidentifier] NOT NULL ,
  58.     [Url] [nvarchar] (500) NULL ,
  59.     CONSTRAINT [PK_Servers] PRIMARY KEY  CLUSTERED (
  60.         [ServerId]
  61.     ) ,
  62.     CONSTRAINT [IX_Servers] UNIQUE  NONCLUSTERED (
  63.         [ServerGuid]
  64.     )
  65. )
  66. GO
  67.  
  68. CREATE TABLE [DLStations] (
  69.     [ServerId] [int] NOT NULL ,
  70.     [CompId] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
  71.     [NetworkAddr] [nvarchar] (50) NULL ,
  72.     [Endpoint] [nvarchar] (50) NULL ,    
  73.     [LastScanTime] [datetime] NULL ,
  74.     [NeedToScan] [bit] NOT NULL DEFAULT (1) ,
  75.     [AttemptsCount] [int] NOT NULL DEFAULT (0) ,
  76.     CONSTRAINT [PK_Stations] PRIMARY KEY  CLUSTERED (
  77.         [ServerId],
  78.         [CompId]
  79.     )    
  80. )
  81. GO
  82.  
  83. CREATE TABLE [DLUsers] (
  84.     [ServerId] [int] NOT NULL ,
  85.     [UserId] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
  86.     [SID] [nvarchar] (255) NOT NULL ,
  87.     [UserName] [nvarchar] (50) NULL ,
  88.     CONSTRAINT [PK_Users] PRIMARY KEY  CLUSTERED (
  89.         [ServerId],
  90.         [UserId]
  91.     )
  92. )
  93. GO 
  94.  
  95. CREATE TABLE [DLShadowFiles] (
  96.     [ServerId] [int] NOT NULL ,
  97.     [ShadowId] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
  98.     [CompId] [int] NOT NULL ,
  99.     [OriginalFileName] [nvarchar] (1500) NULL ,
  100.     [CreationDate] [bigint] NULL ,
  101.     [DeviceType] [int] NULL ,
  102.     [OperationType] [int] NULL ,
  103.     [ProcessName] [nvarchar] (1500) NULL ,
  104.     [Pid] [int] NULL ,
  105.     [StartingOffset] [bigint] NOT NULL DEFAULT (0) ,
  106.     [ShadowSize] [bigint] NOT NULL DEFAULT (0) ,
  107.     [IsFastRebuild] [bit] NOT NULL DEFAULT (0) ,
  108.     [IOErrFile] [image] NULL ,
  109.     [XMLFile] [ntext] NOT NULL ,
  110.     [StoreId] [int] NULL ,
  111.     [Attributes] [int] NOT NULL DEFAULT (0) ,
  112.     [Status] [int] NOT NULL DEFAULT (0) ,    
  113.     [DeletionDate] [bigint] NULL ,
  114.     [DelUserId] [int] NULL ,
  115.     [DelCompId] [int] NULL ,    
  116.     CONSTRAINT [PK_ShadowFiles] PRIMARY KEY  CLUSTERED (
  117.         [ServerId],
  118.         [ShadowId]        
  119.     ) ,
  120.     CONSTRAINT [IX_ShadowFiles] UNIQUE  NONCLUSTERED (
  121.         [ServerId],
  122.         [ShadowId]
  123.     )
  124. )
  125. GO
  126.  
  127. CREATE TABLE [DLShadowFiles_Users] (
  128.     [ServerId] [int] NOT NULL ,
  129.     [ShadowId] [int] NOT NULL ,
  130.     [UserId] [int] NOT NULL ,
  131.     [Flag] [int] NOT NULL DEFAULT (0) ,
  132.     CONSTRAINT [PK_ShadowFiles_Users] PRIMARY KEY  CLUSTERED (
  133.         [ServerId],
  134.         [ShadowId],
  135.         [UserId]
  136.     )
  137. )
  138. GO
  139.  
  140. CREATE TABLE [DLStore] (
  141.     [ServerId] [int] NOT NULL ,
  142.     [StoreId] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
  143.     [DataSize] [bigint] NOT NULL DEFAULT (0) ,
  144.     [DigestSHA1] [binary] (20) NULL ,
  145.     [DigestMD5] [binary] (16) NULL ,
  146.     [CRC32] [binary] (4) NULL ,
  147.     [RealSize] [bigint] NOT NULL DEFAULT (0) ,
  148.     [Location] [tinyint] NOT NULL DEFAULT (0) ,
  149.     [ContentType] [int] NULL ,
  150.     CONSTRAINT [PK_Store] PRIMARY KEY  CLUSTERED (
  151.         [ServerId],
  152.         [StoreId]
  153.     )
  154. )
  155. GO
  156.  
  157. CREATE TABLE [DLStoreBin] (
  158.     [ServerId] [int] NOT NULL ,
  159.     [StoreId] [int] NOT NULL ,
  160.     [PartId] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
  161.     [Data] [image] NULL ,
  162.     CONSTRAINT [PK_StoreBin] PRIMARY KEY  CLUSTERED (
  163.         [ServerId],
  164.         [StoreId],
  165.         [PartId]
  166.     )    
  167. )
  168. GO
  169.  
  170. CREATE TABLE [DLStoreUrl] (
  171.     [ServerId] [int] NOT NULL ,
  172.     [StoreId] [int] NOT NULL ,
  173.     [Url] [ntext] NOT NULL ,
  174.     CONSTRAINT [PK_StoreUrl] PRIMARY KEY  CLUSTERED (
  175.         [ServerId],
  176.         [StoreId]
  177.     )
  178. )
  179. GO
  180.  
  181. CREATE TABLE [DLEvents] (
  182.     [ServerId] [int] NOT NULL ,
  183.     [EventId] [int] IDENTITY (1, 1) NOT NULL ,
  184.     [LogTime] [datetime] NOT NULL ,
  185.     [Severity] [int] NOT NULL ,
  186.     [EventCode] [int] NULL ,
  187.     [Message] [nvarchar] (1000) NULL ,
  188.     CONSTRAINT [PK_Events] PRIMARY KEY  CLUSTERED (
  189.         [ServerId],
  190.         [EventId]
  191.     )    
  192. )
  193. GO
  194.  
  195. CREATE TABLE [DLAuditLog] (
  196.     [ServerId] [int] NOT NULL ,
  197.     [RecordId] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
  198.     [CompId] [int] NOT NULL ,
  199.     [UserId] [int] NULL ,
  200.     [CreationDate] [bigint] NULL ,
  201.     [EventId] [int] NULL ,
  202.     [Type] [smallint] NULL ,
  203.     [ProcessName] [nvarchar] (1500) NULL ,
  204.     [Pid] [int] NULL ,
  205.     [DeviceType] [nvarchar] (500) NULL ,
  206.     [Action] [nvarchar] (500) NULL ,
  207.     [Name] [nvarchar] (500) NULL ,
  208.     [Info] [nvarchar] (500) NULL ,
  209.     [CustomData] [ntext] NULL ,
  210.     CONSTRAINT [PK_DLAuditLog] PRIMARY KEY  CLUSTERED 
  211.     (
  212.         [ServerId],
  213.         [RecordId]
  214.     )
  215. )
  216. GO
  217.  
  218. CREATE TABLE [DLSettings] (
  219.     [Name] [nvarchar] (50) NOT NULL ,
  220.     [Value] [nvarchar] (50) NOT NULL ,
  221.     [ServerId] [int] NULL ,
  222.     [CompId] [int] NULL
  223. )
  224. GO
  225.  
  226. CREATE TABLE [DLSchema] (
  227.     [SchemaVersion] [int] NOT NULL DEFAULT (10)
  228. )
  229. GO
  230.  
  231. INSERT INTO [DLSchema] ([SchemaVersion]) VALUES (17)
  232.  
  233. GO
  234.  
  235. ALTER TABLE [DLEvents] ADD 
  236.     CONSTRAINT [FK_Events_Servers] FOREIGN KEY 
  237.     (
  238.         [ServerId]
  239.     ) REFERENCES [DLServers] (
  240.         [ServerId]
  241.     ) ON UPDATE CASCADE 
  242. GO
  243.  
  244. ALTER TABLE [DLShadowFiles] ADD 
  245.     CONSTRAINT [FK_ShadowFiles_Servers] FOREIGN KEY 
  246.     (
  247.         [ServerId]
  248.     ) REFERENCES [DLServers] (
  249.         [ServerId]
  250.     ) ON UPDATE CASCADE ,
  251.     CONSTRAINT [FK_ShadowFiles_Stations] FOREIGN KEY 
  252.     (
  253.         [ServerId],
  254.         [CompId]
  255.     ) REFERENCES [DLStations] (
  256.         [ServerId],
  257.         [CompId]
  258.     ),
  259.     CONSTRAINT [FK_ShadowFiles_Store] FOREIGN KEY 
  260.     (
  261.         [ServerId],
  262.         [StoreId]
  263.     ) REFERENCES [DLStore] (
  264.         [ServerId],
  265.         [StoreId]
  266.     ),
  267.     CONSTRAINT [FK_DelShadowFiles_Stations] FOREIGN KEY 
  268.     (
  269.         [ServerId],
  270.         [DelCompId]
  271.     ) REFERENCES [dbo].[DLStations] (
  272.         [ServerId],
  273.         [CompId]
  274.     ),
  275.     CONSTRAINT [FK_DelShadowFiles_Users] FOREIGN KEY 
  276.     (
  277.         [ServerId],
  278.         [DelUserId]
  279.     ) REFERENCES [dbo].[DLUsers] (
  280.         [ServerId],
  281.         [UserId]
  282.     )
  283. GO
  284.  
  285. ALTER TABLE [DLShadowFiles_Users] ADD 
  286.     CONSTRAINT [FK_ShadowFiles_Users_Servers] FOREIGN KEY 
  287.     (
  288.         [ServerId]
  289.     ) REFERENCES [DLServers] (
  290.         [ServerId]
  291.     ) ON UPDATE CASCADE ,
  292.     CONSTRAINT [FK_ShadowFiles_Users_ShadowFiles] FOREIGN KEY 
  293.     (
  294.         [ServerId],
  295.         [ShadowId]
  296.     ) REFERENCES [DLShadowFiles] (
  297.         [ServerId],
  298.         [ShadowId]
  299.     ),
  300.     CONSTRAINT [FK_ShadowFiles_Users_Users] FOREIGN KEY 
  301.     (
  302.         [ServerId],
  303.         [UserId]
  304.     ) REFERENCES [DLUsers] (
  305.         [ServerId],
  306.         [UserId]
  307.     )
  308. GO
  309.  
  310. ALTER TABLE [DLStations] ADD 
  311.     CONSTRAINT [FK_Stations_Servers] FOREIGN KEY 
  312.     (
  313.         [ServerId]
  314.     ) REFERENCES [DLServers] (
  315.         [ServerId]
  316.     ) ON UPDATE CASCADE 
  317. GO
  318.  
  319. ALTER TABLE [DLStore] ADD 
  320.     CONSTRAINT [FK_Store_Servers] FOREIGN KEY 
  321.     (
  322.         [ServerId]
  323.     ) REFERENCES [DLServers] (
  324.         [ServerId]
  325.     ) ON UPDATE CASCADE 
  326. GO
  327.  
  328. ALTER TABLE [DLStoreBin] ADD 
  329.     CONSTRAINT [FK_StoreBin_Servers] FOREIGN KEY 
  330.     (
  331.         [ServerId]
  332.     ) REFERENCES [DLServers] (
  333.         [ServerId]
  334.     ) ON UPDATE CASCADE ,
  335.     CONSTRAINT [FK_StoreBin_Store] FOREIGN KEY 
  336.     (
  337.         [ServerId],
  338.         [StoreId]
  339.     ) REFERENCES [DLStore] (
  340.         [ServerId],
  341.         [StoreId]
  342.     ) NOT FOR REPLICATION 
  343. GO
  344.  
  345. ALTER TABLE [DLStoreUrl] ADD 
  346.     CONSTRAINT [FK_StoreUrl_Servers] FOREIGN KEY 
  347.     (
  348.         [ServerId]
  349.     ) REFERENCES [DLServers] (
  350.         [ServerId]
  351.     ) ON UPDATE CASCADE ,
  352.     CONSTRAINT [FK_StoreUrl_Store] FOREIGN KEY 
  353.     (
  354.         [ServerId],
  355.         [StoreId]
  356.     ) REFERENCES [DLStore] (
  357.         [ServerId],
  358.         [StoreId]
  359.     ) NOT FOR REPLICATION 
  360. GO
  361.  
  362. ALTER TABLE [DLUsers] ADD 
  363.     CONSTRAINT [FK_Users_Servers] FOREIGN KEY 
  364.     (
  365.         [ServerId]
  366.     ) REFERENCES [DLServers] (
  367.         [ServerId]
  368.     ) ON UPDATE CASCADE 
  369. GO
  370.  
  371. ALTER TABLE [DLAuditLog] ADD 
  372.     CONSTRAINT [FK_DLAuditLog_DLServers] FOREIGN KEY 
  373.     (
  374.         [ServerId]
  375.     ) REFERENCES [DLServers] (
  376.         [ServerId]
  377.     ) ON UPDATE CASCADE ,
  378.     CONSTRAINT [FK_DLAuditLog_DLStations] FOREIGN KEY 
  379.     (
  380.         [ServerId],
  381.         [CompId]
  382.     ) REFERENCES [DLStations] (
  383.         [ServerId],
  384.         [CompId]
  385.     ),
  386.     CONSTRAINT [FK_DLAuditLog_DLUsers] FOREIGN KEY 
  387.     (
  388.         [ServerId],
  389.         [UserId]
  390.     ) REFERENCES [DLUsers] (
  391.         [ServerId],
  392.         [UserId]
  393.     )
  394. GO
  395.  
  396. ALTER TABLE [DLSettings] ADD 
  397.     CONSTRAINT [FK_DLSettings_DLServers] FOREIGN KEY 
  398.     (
  399.         [ServerId]
  400.     ) REFERENCES [DLServers] (
  401.         [ServerId]
  402.     ) ON UPDATE CASCADE ,
  403.     CONSTRAINT [FK_DLSettings_DLStations] FOREIGN KEY 
  404.     (
  405.         [ServerId],
  406.         [CompId]
  407.     ) REFERENCES [DLStations] (
  408.         [ServerId],
  409.         [CompId]
  410.     )
  411. GO
  412.